<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>position: sticky test</title>
    <style>
        .box {
            width: 100px;
            height: 100px;
            border: 1px solid black;
            margin: 10px;
            display: inline-block;
        }
        .box.sticky {
            position: sticky;
            top: 10px;
        }

        .main {
            position: relative;
            background-color: aliceblue;
        }

        .top, .bottom {
            height: 1500px;
            margin: 10px;
            background-color: #eee;
        }
    </style>
</head>
<body>
    <div class="top">top</div>
    <div class="main" style="height: 900px">
        <div class="desc">这个包含stiky元素的容器，如果也滚到视口外，则sticky元素也跟随离开，不在sticky了</div>
        <div class="box">1</div>
        <div class="box sticky">2 sticky</div>
        <div class="box">3</div>

    </div>
    <div class="bottom">bottom</div>
</body>
</html>